#include "lcd.h"

#include "lcd_controller.h"

void lcd_test(void) {
    uint32 fb_base;
    int xres, yres, bpp;
    int x, y;
    uint16 *p;
    uint32 *p2;

    lcd_init();

    lcd_enable();

    get_lcd_params(&fb_base, &xres, &yres, &bpp);

    if (bpp == 16) {
        p = (uint16 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p++ = 0xf800;

        /* green */
        p = (uint16 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p++ = 0x7e0;

        /* blue */
        p = (uint16 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p++ = 0x1f;

    } else if (bpp == 32) {
        p2 = (uint32 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p2++ = 0xff0000;

        /* green */
        p2 = (uint32 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p2++ = 0x00ff00;

        /* blue */
        p2 = (uint32 *)fb_base;
        for (x = 0; x < xres; x++)
            for (y = 0; y < yres; y++) *p2++ = 0x0000ff;
    }
}